import u from "../utils";
import { APP } from "../constants";
import { WeaLocaleProvider } from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;

const _api = u.api(APP);

export default {
    getApps: params => _api('list', { data: params }),
    getLeftDatas: params => _api('getLeftDatas', { data: params }),
    getDisplayTypes: () => _api('getDisplayType'),
    getFillinTypes: () => _api('getFillinType'),
    info: appid => _api('info', {
        type: 'get',
        data: { appid }
    }),
    create: (appinfo) => _api('create', {
        type: 'post',
        data: { appinfo: JSON.stringify(appinfo)},
        msg: getLabel('502228', '新建成功')
    }),
    edit: (appinfo) => _api('modify', {
        type: 'post',
        data: { appinfo: JSON.stringify(appinfo)},
        msg: getLabel('502229', '编辑成功')
    }),
    delete: appids => _api('delete', {
        data: { appids },
        msg: getLabel('502230', '删除成功')
    }),
    getBoard: appid => _api('getBoardInfoWithApp', { data: { appid } }),
    existsForm: appid => _api('existsForm', { data: { appid } }),
    share: share => _api('share', { data: share, type: 'post' }),
    getSearchItems: params => _api('getSearchItems', { data: params, type: 'get' }),
    checkCreateMaxNum:params => _api('checkCreateMaxNum',{data: params,type: 'get'})
}

export const shareList = appid => _api('shareList', { data: { appid } });
export const deleteShare = (ids, appid) => _api('deleteShare', { data: { appid, ids }, type: 'post' });